var Observer = function () {
    this.list = {};
};
Observer.prototype = {
    on: function (e, fn) {
        this.list[e] = this.list[e] ? this.list[e] : [];
        this.list[e].push(fn)
    },
    emit: function () {
        var e = Array.prototype.shift.call(arguments);
        if (!this.list[e]) return;
        for (var i = 0; i < this.list[e].length; i++) {
            console.log(this.list[e][i]);
            this.list[e][i](arguments);
        }
    }
};

var test = function (val) {
    var obj = new Object();
    obj.val = val;
    obj.test = function () {
        console.log(obj.val);
    };
    return obj;
};